import java.util.HashSet;
import java.util.Set;

public class test {

    public static Integer a(Integer[] arr){

        Set<Integer> s = new HashSet<Integer>();
        for(Integer x : arr){
            s.add(x);
        }

        Integer resp=0;
        for (Integer x:
             s) {
            if(!s.contains(x-1)){
                Integer x1 = x;
                while (s.contains(x1+1)) x1++;
                resp=Math.max(resp,x1-x);
            }
        }
        return resp;
    }

    public static void main(String[] args) {
        Integer[] test1  = {1000,4,2000,1,3,2};

        System.out.println(a(test1));
    }
}
